package lesson11;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Test03 {
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
//        Collections.addAll(arrayList,5,2,6,1,3,3,1,2,6,8,10,5,4,3);
//        Collections.shuffle(arrayList);

        arrayList.add(new Student("张飞",20,"男"));
        arrayList.add(new Student("小乔",18,"女"));
        arrayList.add(new Student("大乔",25,"女"));
        arrayList.add(new Student("关羽",22,"男"));
        arrayList.add(new Student("曹操",28,"男"));
//        Collections.sort(arrayList,new MyComparator());
        Collections.sort(arrayList, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge() - o2.getAge();
            }
        });
        System.out.println(arrayList);
    }
}
